package cn.com.cifi.mars.mapper.wrapper;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.com.cifi.mars.bean.dto.NosTradeDto;
import cn.com.cifi.mars.entity.PanoplanBuildPlanItem;
import cn.com.cifi.mars.entity.PanoplanBuildPlanItemDetail;
import cn.com.cifi.mars.entity.ReturnCoefficientDetail;
import cn.com.cifi.mars.mapper.mars.ReturnCoefficientDetailMapper;

/**
 * @author: JingYuanXiang
 * @date: 2020/11/9 16:52
 */
@Component
public class ReturnCoefficientDetailWrapper  {

    @Autowired
    private ReturnCoefficientDetailMapper returnCoefficientDetailMapper;

    /**
     * 查询回款系数详情
     *
     * @param coefficientVersionId 回款系数版本id
     * @param isDelete             是否删除
     * @return
     */
    public List<ReturnCoefficientDetail> selectByCoefficientId(String coefficientVersionId, int isDelete) {
        QueryWrapper<ReturnCoefficientDetail> queryWrapper = new QueryWrapper();
        queryWrapper.eq("coefficient_id", coefficientVersionId)
                .eq("is_delete", isDelete)
                .orderByAsc("pro_product_code");
        return returnCoefficientDetailMapper.selectList(queryWrapper);
    }

    /**
     * 查询回款系数详情列表
     * @param coefficientVersionIdList 回款系数版本id列表
     * @param isDelete 是否删除
     * @return
     */
    public List<ReturnCoefficientDetail> selectByCoefficientIdList(List<String> coefficientVersionIdList, int isDelete) {
        QueryWrapper<ReturnCoefficientDetail> queryWrapper = new QueryWrapper();
        queryWrapper.in("coefficient_id", coefficientVersionIdList)
                .eq("is_delete", isDelete);
        return returnCoefficientDetailMapper.selectList(queryWrapper);
    }

    /**
     * 查询最新版回款系数
     * @param coefficientId 回款系数版本id
     * @param isDelete 是否删除
     * @return
     */

    public List<ReturnCoefficientDetail>   selectNewestByCoefficientId(String coefficientId, int isDelete) {
        QueryWrapper<ReturnCoefficientDetail> queryWrapper = new QueryWrapper();
        queryWrapper.eq("coefficient_id", coefficientId)
                .eq("is_delete", isDelete)
                .orderByAsc("pro_product_code")
                .orderByDesc("create_time");
        return returnCoefficientDetailMapper.selectList(queryWrapper);
    }

    public void update(String versionId, String userName, int isDel) {
        returnCoefficientDetailMapper.updateByCoefficientId(versionId,userName,isDel);
    }

    public List<PanoplanBuildPlanItem> queryBySingIdList(List<String> singIdList) {
        return returnCoefficientDetailMapper.queryBySingIdList(singIdList);
    }

    public List<PanoplanBuildPlanItemDetail> queryByPkIdList(List<String> pkIds) {
        return returnCoefficientDetailMapper.queryByPkIdList(pkIds);
    }

    public List<ReturnCoefficientDetail> selectNewestByCoefficientIds(String id, int isDel) {
        return returnCoefficientDetailMapper.queryByCoefficientIds(id,isDel);
    }

    public List<String> queryStagesIdByProjectId(String projectId) {
        return returnCoefficientDetailMapper.queryStagesIdByProjectId(projectId);
    }

    public Set<String> queryFetchNum(List<String> stagesIds) {
        return returnCoefficientDetailMapper.queryFetchNum(stagesIds);
    }

    public List<NosTradeDto> selectMymContractListForNos(String projectId) {
        return returnCoefficientDetailMapper.queryMymContractListForNos(projectId);
    }

	public List<Map<String, Object>> queryProductCodeBySingIdList(List<String> singIdList) {
		return returnCoefficientDetailMapper.queryProductCodeBySingIdList(singIdList);
	}


}
